/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ufcg.dsc.lsi.vademecum.util;

/**
 *
 * @author Hugo
 */
public class URLUtils {

    public static String urlEncode(String str) {
        StringBuffer buf = new StringBuffer();
        char c;
        for (int i = 0; i < str.length(); i++) {
            c = str.charAt(i);
            if ((c >= '0' && c <= '9') ||
                    (c >= 'A' && c <= 'Z') ||
                    (c >= 'a' && c <= 'z')) {
                buf.append(c);
            } else {
                buf.append("%").append(Integer.toHexString((int) str.charAt(i)));
            }
        }
        return buf.toString();
    }
}
